package components.dialogs.adjustments
{
	import UIFree.uif_component;
	
	import classes.Commands.c_applyAnimEffect;
	
	import MLP.mlp_effects;
	import components.dialogs.c_elementPropDlg;
	import components.dialogs.c_propertyDialog;
	import components.editor.c_baseElement;
	import components.editor.c_effectElement;
	
	public class c_AnimEffectDialog extends c_elementPropDlg {
		private var _prevIndex: int;
		public function c_AnimEffectDialog(parent:uif_component, a_element: c_effectElement, a_title:String='', modal:Boolean=false, canClose:int=2) {
			_prevIndex = mlp_effects.effectIndex(a_element.params?a_element.params.id:0) as int;
			super(parent, a_element, [{
				title	: 'Тип анимации',
				type	: c_propertyDialog.PTYPE_COMBO,
				value	: _prevIndex,
				items	: animList
			}], a_title, modal, canClose);
		}
		
		protected function get effectElement(): c_effectElement {
			return element as c_effectElement; 
		}
		
		public function get animList(): Array {
			return mlp_effects.list;
		}
		
		protected function get curSelectParam(): Object {
			return values[0].value;
		}
		
		override protected function updateElement(): void {
			if (curSelectParam) effectElement.params = curSelectParam;
		}	
		
		override protected function doCancel(): void {
			effectElement.params = animList[_prevIndex];
		}
		
		override protected function doApply(): void {
			executeCommand(new c_applyAnimEffect(effectElement, curSelectParam, animList[_prevIndex]));
		}
	}
}